package C031;

/**
 * ClassName: Code02_PowerOfThree
 * Package: C031
 * Description: 这里的前置知识是 3的幂的数只有3一个质数因子
 *
 * @Author BCXJ
 * @Create 2024/12/27 16:10
 * @Version 1.0
 * @Since 1.0
 */
public class Code02_PowerOfThree {
    public static void main(String[] args) {
        System.out.println((int) Math.pow(3, 19)); // int范围内的最大值1162261467
        System.out.println((int) Math.pow(3, 20)); // 2147483647
        System.out.println((int) Math.pow(3, 21));  //2147483647
        System.out.println((int) Math.pow(3, 22)); // 2147483647 int的最大值
        System.out.println((int) Math.pow(3, 100)); //2147483647
        System.out.println(2147483647 + 1); //-2147483648

        System.out.println(powerOfThree(9));
        System.out.println(powerOfThree(18));
        System.out.println(powerOfThree(27));
    }

    public static boolean powerOfThree(int n) {
        return 1162261467 % n == 0;
    }
}
